home *** CD-ROM | disk | FTP | other *** search
- <IMG NAME=arrow SRC="arrow.gif" ALIGN=left>
-
- <DIV ID=banner STYLE="position: absolute; left: 72; top: 15;">
- <FONT FACE="Arial, Helvetica" SIZE=+2>
- Exposing Page Elements Cross-Browser
- </FONT>
- </DIV>
-
-
- <SCRIPT>
- // Detect if browser is IE4 and if so, assign objectRoot to contain
- // 'document.all' instead of 'document'
- //
- objectRoot = "document";
- if (navigator.appName.indexOf("Internet Explorer") != -1 &&
- navigator.appVersion.charAt(0) == '4')
- objectRoot = "document.all";
- </SCRIPT>
-
-
- <BR><BR>
- <P>The <TT>DIV</TT> element is normally reflected as
- <TT>document.banner</TT> in Communicator 4.0 and
- <TT>document.all.banner</TT> in IE4. By assigning
- <TT>objectRoot</TT> to contain the differences in the object hierarchy,
- the <TT>eval()</TT> function can be used to dynamically access the
- <TT>DIV</TT> element using the correct notation for each browser.</P>
-
- <P>The attributes of the <TT>DIV</TT> element that are reflected in both
- browsers include:</P>
-
- <BLOCKQUOTE>
- <SCRIPT>
- document.writeln("<B>id:</B> " + eval(objectRoot + ".banner.id"));
- document.writeln("<BR>");
- </SCRIPT>
- </BLOCKQUOTE>
-
- <P>The <TT>IMG</TT> element is dynamically accessed as
- <TT>document.arrow</TT> in Communicator 4.0 and
- <TT>document.all.arrow</TT> in IE4 using the <TT>objectRoot</TT>
- variable and the <TT>eval()</TT> function. </P>
-
- <P>The attributes of the <TT>IMG</TT> element that are reflected in both
- browsers include:</P>
-
- <BLOCKQUOTE>
- <SCRIPT>
- document.writeln("<B>name:</B> " + eval(objectRoot + ".arrow.name"));
- document.writeln("<BR>");
- document.writeln("<B>src:</B> " + eval(objectRoot + ".arrow.src"));
- document.writeln("<BR>");
- </SCRIPT>
- </BLOCKQUOTE>
-